class Offer < ActiveRecord::Base
  #
  # Relations
  #

  belongs_to :ad, :class_name => 'Ad', :autosave => true
  belongs_to :user, :class_name => 'User'
  has_many :comments

  #
  # Validation
  #

  validates :title, :presence => true
  validates :content, :presence => true

  #
  # Methods
  #

  def initialize(params=nil)
    if params
      params[:user] = User.current
      params[:ad] = Ad.find(params[:ad].to_i)
      params[:border_left] = 1
      params[:border_right] = 4
    end
    super
  end
end
